﻿using System.Windows.Documents;

using VSTalk.Engine.ViewModel.Messenger.History;
using VSTalk.Engine.ViewModel.Messenger.ThreadRenderer.BlockBuilder;
using VSTalk.Engine.ViewModel.Messenger.ThreadRenderer.Model;

namespace VSTalk.Engine.ViewModel.Messenger.ThreadRenderer.Command
{
    public class RenderHistoryLoader : BaseRenderingCommand
    {
        private HistoryCommandMessage _message;

        private HistoryBlockBuilder _builder;

        public RenderHistoryLoader(ConversationModel conversationModel, HistoryCommandMessage message)
                : base(conversationModel)
        {
            _message = message;

            _builder = new HistoryBlockBuilder();
        }

        public override void Execute()
        {
            var section = new ConversationSection
            {
                Content = new Section(),
                Type = SectionType.HistoryControl
            };
            var block = _builder.CreateBlock(_message);
            section.Content.Blocks.Add(block);
            ConversationModel.AddFirst(section);
        }
    }
}